/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;

/**
 *
 * @author HoangLiem
 */
public class FillDatabaseNames extends Thread {

    private ObjectInputStream objectInputStream = null;
    private JComboBox combobox;

    public FillDatabaseNames(ObjectInputStream ois, JComboBox combo) {
        this.objectInputStream = ois;
        this.combobox = combo;
        start();
    }

    public void run() {
        try {
            ArrayList<String> databaseNames = (ArrayList<String>) objectInputStream.readObject();
            if (databaseNames != null && !databaseNames.isEmpty()) {
                for (int i = 0; i < databaseNames.size(); i++) {
                    combobox.addItem(databaseNames.get(i));
                }
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(FillDatabaseNames.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
